package com.qbw.app.module.common.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.Nullable;

import com.qbw.app.request.ErrorCode;
import com.qbw.app.module.user.activity.UserLoginRegistActivity;

/**
 * @author qinbaowei
 * @date 2018/3/29
 * @email qbaowei@qq.com
 */

public class EmptyActivity extends Activity {

    private static final String KEY_ERROR_CODE = "error_code";

    private int mErrorCode;

    public static void startActivity(Context context, int errorCode) {
        Intent intent = new Intent(context, EmptyActivity.class);
        if (!(context instanceof Activity)) {
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        }
        intent.putExtra(KEY_ERROR_CODE, errorCode);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle args = savedInstanceState == null ? getIntent().getExtras() : savedInstanceState;
        mErrorCode = args.getInt(KEY_ERROR_CODE);
        if (mErrorCode == ErrorCode.VT_TOKEN_INVALID) {
            finishAffinity();
            UserLoginRegistActivity.start(this);
        }
    }
}
